package com.why.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.why.mapper.ManageMapper;
import com.why.pojo.*;
import com.why.pojo.vo.ManageVo;
import com.why.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author new wei
 * @date 2022/5/16 9:33
 */
@Service
@Transactional
public class ManageServiceImpl implements ManageService {
    @Autowired
    ManageMapper manageMapper;

    @Override
    public PageInfo<Manage> list(ManageVo vo, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Manage> list=manageMapper.list(vo);
        PageInfo<Manage> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Venue> getVid() {
        return manageMapper.getVid();
    }

    @Override
    public List<Type> getTid() {
        return manageMapper.getTid();
    }

    @Override
    public List<Place> getPid() {
        return manageMapper.getPid();
    }

    @Override
    public int addManage(Manage manage) {
        int i=manageMapper.addManage(manage);
        List<Detail> detailList = manage.getDetailList();
        if (null!=detailList&&detailList.size()>0){
            manageMapper.addDetail(detailList,manage.getMid());
        }
        return i;
    }

    @Override
    public List listCount() {
        return manageMapper.listCount();
    }
}
